﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using BHair.Business.BaseData;
using BHair.Business;
using BHair.Business.Table;
using System.IO;
using BHair.Report;
using System.Drawing.Printing;
using System.Data.SqlClient;
using System.Configuration;
using DevExpress.XtraReports.UI;
using DevExpress.XtraReports.UserDesigner;
namespace BHair.Base
{
    public partial class frmMember_List : WeifenLuo.WinFormsUI.Docking.DockContent
    {
        public frmMember_List()
        {
            InitializeComponent();
        }

        private void frmMember_List_Load(object sender, EventArgs e)
        {
            this.LoadMemberList();
            this.LoadMemberNum();
            //jz();
        }
        public void jz()
            {
            string sql = "SELECT [cid] ,[cname] FROM [card]";
            SqlConnection conn = new SqlConnection(constr);
            conn.Open();
            SqlDataAdapter sda = new SqlDataAdapter(sql,conn);
            DataSet ds = new DataSet();
            sda.Fill(ds,"card");
            comboBox2.DataSource = ds.Tables["card"];
            comboBox2.DisplayMember = "cname";
            conn.Close();
        }
        string constr = ConfigurationManager.ConnectionStrings["BHair.Properties.Settings.BHairDBConnectionString"].ConnectionString;
        /// <summary>加载会员信息列表。</summary>
        public void LoadMemberList()
        {
            string strMember = this.txtMember.Text;
            bool bEnabled = this.chkEnabled.Checked;
            List<Member> lstMember = new Member().SelectList(strMember, bEnabled);
            this.dgvMember.AutoGenerateColumns = false;
            this.dgvMember.Rows.Clear();
            decimal dSum = 0;//合计余额
            foreach (Member objMember in lstMember)
            {
                dSum += objMember.Balance;
                this.dgvMember.Rows.Add(new object[] { objMember.ID, objMember.Card.CardName, objMember.Name, objMember.SexText,objMember.Birthday, objMember.Balance, objMember.积分, objMember.Phone, objMember.LastTime, objMember.StatusText, objMember.Other, objMember.Remark });
            }
            this.lblSumBalance.Text = "会员余额合计：￥" + dSum.ToString("f2");
            
            this.lblSumBalance.Top = this.ClientSize.Height - 18;
        }

        /// <summary>加载会员数统计。</summary>
        public void LoadMemberNum()
        {
            //会员总数
            string strNum = Member.GetMemberTotal(0, 0).ToString();
            strNum += "|" + Member.GetMemberTotal(1, 0).ToString();
            strNum += "|" + Member.GetMemberTotal(2, 0).ToString();//5+1+a+s+p+x
            this.lblTotal.Text = "会员数统计：" + strNum;
            this.lblTotal.Top = this.ClientSize.Height - 18;

            //会员类型
            List<Card> lstCard = new Card().SelectList(0);
            this.lblType.Text = "";
            foreach (Card objCard in lstCard)
            {
                this.lblType.Text += objCard.CardName + "：" + objCard.MemberSum.ToString() + "   ";
            }
            this.lblType.Top = this.ClientSize.Height - 18;
        }

        /// <summary>显示不可用会员</summary>
        private void chkEnabled_CheckedChanged(object sender, EventArgs e)
        {
            this.LoadMemberList();
        }

        private void txtMember_TextChanged(object sender, EventArgs e)
        {
            this.LoadMemberList();
        }

        /// <summary>新增会员</summary>
        private void btnAdd_Click(object sender, EventArgs e)
        {
            frmMember objfrmMember = new frmMember();
            if (objfrmMember.ShowDialog() == DialogResult.OK)
            {
                chuanzhi cz = new chuanzhi();
                cz.rizhi("会员发卡");
                this.LoadMemberList();
                this.LoadMemberNum();
            }
        }

        #region 编辑会员信息...

        /// <summary>编辑会员</summary>
        private void btnModify_Click(object sender, EventArgs e)
        {
            chuanzhi cz = new chuanzhi();
            cz.rizhi("修改会员");
            this.ShowMember();
        }

        /// <summary>双击编辑会员信息</summary>
        private void dgvMember_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            if (e.RowIndex > -1)
            {
                this.ShowMember();
            }
        }

        private void ShowMember()
        {
            if (this.dgvMember.CurrentRow != null)
            {
                string strMemberId = this.dgvMember.CurrentRow.Cells[0].Value.ToString();
                frmMember objfrmMember = new frmMember(strMemberId);
                if (objfrmMember.ShowDialog() == DialogResult.OK)
                {
                    this.LoadMemberList();
                }
            }
        }

        #endregion

        #region 会员充值...

        /// <summary>会员充值</summary>
        private void btnRecharge_Click(object sender, EventArgs e)
        {
            this.MemberRecharge();
        }

        /// <summary>会员充值</summary>
        private void cmnuMember_Recharge_Click(object sender, EventArgs e)
        {
            this.MemberRecharge();
        }

        /// <summary>会员充值</summary>
        private void MemberRecharge()
        {
            if (this.dgvMember.CurrentRow != null)
            {
                string strMemberId = this.dgvMember.CurrentRow.Cells[0].Value.ToString();
                if (new Member(strMemberId).Status == 1)
                {
                    MessageBox.Show("当前会员状态不可用，不能进行充值操作！", "消息", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
                else
                {
                    frmDeposit_Add objfrmDepositAdd = new frmDeposit_Add(strMemberId);
                    if (objfrmDepositAdd.ShowDialog() == DialogResult.OK)
                    {
                        this.LoadMemberList();
                    }
                }
            }
        }

        /// <summary>查看充值记录</summary>
        private void cmnuMember_RechargeLog_Click(object sender, EventArgs e)
        {
            if (this.dgvMember.CurrentRow != null)
            {
                string strMemberId = this.dgvMember.CurrentRow.Cells[0].Value.ToString();
                frmMember_Recharge objMemberRecharge = new frmMember_Recharge(strMemberId);
                objMemberRecharge.ShowDialog();
            }
        }

        #endregion

        /// <summary>右键选取</summary>
        private void dgvMember_MouseDown(object sender, MouseEventArgs e)
        {
            DataGridView.HitTestInfo rows = this.dgvMember.HitTest(e.X, e.Y);
            if (e.Button == MouseButtons.Right)
            {
                if (rows.RowIndex > -1 && rows.ColumnIndex > -1)
                {
                    //定位
                    this.dgvMember.ClearSelection();
                    this.dgvMember.Rows[rows.RowIndex].Selected = true;
                    this.dgvMember.CurrentCell = this.dgvMember.Rows[rows.RowIndex].Cells[rows.ColumnIndex];

                    string strMemberID = this.dgvMember.CurrentRow.Cells[0].Value.ToString();
                    Member objMember = new Member(strMemberID);
                    if (objMember.Status == 0)
                    {
                        //正常
                        this.cmnuMember_Recharge.Enabled = true;

                        this.cmnuMember_Exchange.Enabled = true;//换卡
                        this.cmnuMember_Back.Enabled = 
                            true;//退卡
                    }
                    else
                    {
                        //停用
                        this.cmnuMember_Recharge.Enabled = false;

                        this.cmnuMember_Exchange.Enabled = false;//换卡
                        this.cmnuMember_Back.Enabled = false;//退卡
                    }
                    this.cmnuMember_Transfer.Enabled = true;
                    this.cmnuMember_PaysLog.Enabled = true;
                    this.cmnuMember_RechargeLog.Enabled = true;
                }
                else
                {
                    this.cmnuMember_Recharge.Enabled = false;//充值
                    this.cmnuMember_Transfer.Enabled = false;//转账
                    this.cmnuMember_PaysLog.Enabled = false;//消费记录
                    this.cmnuMember_RechargeLog.Enabled = false;//充值记录
                    this.cmnuMember_Exchange.Enabled = false;//换卡
                    this.cmnuMember_Back.Enabled = false;//退卡
                }
            }
        }

        /// <summary>新增消费</summary>
        private void cmnuMember_Pays_Click(object sender, EventArgs e)
        {
            if (this.dgvMember.CurrentRow != null)
            {
                string strMemberId = this.dgvMember.CurrentRow.Cells[0].Value.ToString();
                frmMember_Pay objMemberPay = new frmMember_Pay(strMemberId);
                objMemberPay.ShowDialog();
            }
        }
        /// <summary>余额转帐</summary>
        private void cmnuMember_Transfer_Click(object sender, EventArgs e)
        {
            if (this.dgvMember.CurrentRow != null)
            {
                chuanzhi cz = new chuanzhi();
                cz.rizhi("余额转账");
                string strMemberId = this.dgvMember.CurrentRow.Cells[0].Value.ToString();
                frmMember_Transfer objfrmMemberTransfer = new frmMember_Transfer(strMemberId);
                if (objfrmMemberTransfer.ShowDialog() == DialogResult.OK)
                {
                    this.LoadMemberList();
                }
            }
        }

        /// <summary>查看消费记录</summary>
        private void cmnuMember_PaysLog_Click(object sender, EventArgs e)
        {
            if (this.dgvMember.CurrentRow != null)
            {
                string strMemberId = this.dgvMember.CurrentRow.Cells[0].Value.ToString();
                frmMember_Pay objMemberPay = new frmMember_Pay(strMemberId);
                objMemberPay.ShowDialog();
            }
        }

        /// <summary>会员换卡</summary>
        private void cmnuMember_Exchange_Click(object sender, EventArgs e)
        {
            if (this.dgvMember.CurrentRow != null)
            {
                chuanzhi cz = new chuanzhi();
                cz.rizhi("会员换卡");
                /* string cardid = this.dgvMember.CurrentRow.Cells[0].Value.ToString();
                 //更换卡号
                 SqlConnection conn = new SqlConnection(constr);
                 conn.Open();
                 string sql1 = string.Format("UPDATE [member] SET [mid] = '{0}' WHERE mid='{1}'", cardid, cardid);
                 SqlCommand comm = new SqlCommand(sql1,conn);
                 comm.ExecuteNonQuery();
                 //修改csmx
                 SqlConnection conn2 = new SqlConnection(constr);
                 conn2.Open();
                 string sql2 =string "UPDATE [BHairDB23].[dbo].[csmx] SET [cardID] = ''  WHERE cardID=''";*/
                string strMemberId = this.dgvMember.CurrentRow.Cells[0].Value.ToString();
                Member.oldcard = strMemberId;
                frmMember_Exchange objMemberExchange = new frmMember_Exchange(strMemberId);
                if (objMemberExchange.ShowDialog() == DialogResult.OK)
                {
                    this.LoadMemberList();
                }



            }
        }

        /// <summary>刷新</summary>
        private void cmnuMember_Refresh_Click(object sender, EventArgs e)
        {
            this.LoadMemberList();
            this.LoadMemberNum();
        }

        /// <summary>会员退卡</summary>
        private void cmnuMember_Back_Click(object sender, EventArgs e)
        {
            if (this.dgvMember.CurrentRow != null)
            {
               
                chuanzhi cz = new chuanzhi();
                cz.rizhi("会员退卡,卡号："+ this.dgvMember.CurrentRow.Cells[0].Value.ToString());
                //删除卡内项目
                SqlConnection conn = new SqlConnection(constr);
                conn.Open();
                string sql =string.Format( "DELETE FROM [BHairDB].[dbo].[csmx] WHERE cardID='{0}'", this.dgvMember.CurrentRow.Cells[0].Value.ToString());
                SqlCommand comm = new SqlCommand(sql,conn);
                comm.ExecuteNonQuery();

                string strMemberId = this.dgvMember.CurrentRow.Cells[0].Value.ToString();
                Member objMember = new Member(strMemberId);
                if (MessageBox.Show("会员【" + objMember.ID + "】" + objMember.Name + "\n当前余额：￥" + objMember.Balance.ToString("f2") + "\n确实要退卡吗？", "消息", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    Deposit objDeposit = new Deposit();
                    objDeposit.Mode = 4;
                    objDeposit.MemberID = objMember.ID;
                    objDeposit.Money = 0 - objMember.Balance;
                    objDeposit.Date = DateTime.Now;
                    if (objDeposit.BackDeposit() > 0)
                    {
                        objMember.Remark = objDeposit.Date.ToShortDateString() + "退卡";
                        objMember.UpdateStatus();//更新会员状态
                        objMember.UpdateBalance(objMember.ID);//更新会员余额

                        //新增支出
                        Subject objSubject = new Subject();
                        objSubject.ID = objSubject.ExistsSubjectName("退卡");
                        if (objSubject.ID == 0)
                        {
                            objSubject.Name = "退卡";
                            objSubject.Readme = "会员退卡";
                            objSubject.Type = 0;
                            objSubject.ID = objSubject.InsertSubject();
                        }

                        WasteBook objWasteBook = new WasteBook();
                        objWasteBook.SubjectID = objSubject.ID;
                        objWasteBook.Income = 0;
                        objWasteBook.Expend = objMember.Balance;
                        objWasteBook.Date = objDeposit.Date;
                        objWasteBook.Remark = "会员卡号【" + objMember.ID + "】" + objMember.Name;
                        objWasteBook.Type = "e";
                        objWasteBook.InsertWasteBook();
                        chuanzhi.tkcard = this.dgvMember.CurrentRow.Cells[0].Value.ToString();
                        退卡提示 t = new 退卡提示();
                        t.ShowDialog();
                        this.LoadMemberList();
                        this.LoadMemberNum();
                    }
                }
            }
        }

        private void dgvMember_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
        {
            StaticValue.ShowRows_DataGridView_RowPostPaint(this.dgvMember, sender, e);
        }

        private void btnPrint_Click(object sender, EventArgs e)
        {

            this.printPreviewDialog1.ShowDialog();//打印预览
            //printDocument1.Print();//直接打印
           //rintDataGridView PrintDataGridView = new PrintDataGridView();
           //rintDataGridView.Print(dgvMember, "会员报表");



            //DataGridViewPrint DataGridViewPrint = new DataGridViewPrint(dgvMember);

            //printDocument1 = DataGridViewPrint.GetPrintDocument();

            //PageSetupDialog  pageSetupDialog = new PageSetupDialog();
            //pageSetupDialog.Document = printDocument1;
            //pageSetupDialog.PageSettings.Landscape = true;
           
          ////  pageSetupDialog.PageSettings.PaperSize.PaperName = "A4Rotated";

            //pageSetupDialog.ShowDialog();
            //printPreviewDialog1 = new PrintPreviewDialog();
            //printPreviewDialog1.Document = printDocument1;
            //printPreviewDialog1.Height = 600;
            //printPreviewDialog1.Width = 800;
            //printPreviewDialog1.ShowDialog();

            



          //  this.printPreviewDialog1.Document = this.printDocument1;  //设置需要预览的文档
           // this.printPreviewDialog1.ShowDialog();//开始预览
        }

        private void btnExport_Click(object sender, EventArgs e)
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog();
            saveFileDialog.Filter = "Execl files (*.xls)|*.xls";
            saveFileDialog.FilterIndex = 0;
            saveFileDialog.RestoreDirectory = true;
            saveFileDialog.CreatePrompt = true;
            saveFileDialog.Title = "导出Excel文件到";

            saveFileDialog.ShowDialog();

            // 这个一定要加上，要不然，点取消按钮就会提示“索引超出了数组界限”的错误。
            //用saveFileDialog.ShowDialog() == DialogResult.Cancle 不管用，会出现2次存储窗口。
            if (saveFileDialog.FileName == "")
            {

                return;
            }


            Stream myStream;
            myStream = saveFileDialog.OpenFile();
            StreamWriter sw = new StreamWriter(myStream, System.Text.Encoding.GetEncoding("gb2312"));
            string str = "";
            try
            {
                //写标题       
                for (int i = 0; i < dgvMember.ColumnCount; i++)
                {
                    if (i > 0)
                    {
                        str += "\t";
                    }
                    str += dgvMember.Columns[i].HeaderText;
                }
                sw.WriteLine(str);
                //写内容    
                for (int j = 0; j < dgvMember.Rows.Count; j++)
                {
                    string tempStr = "";
                    for (int k = 0; k < dgvMember.Columns.Count; k++)
                    {
                        if (k > 0)
                        {
                            tempStr += "\t";
                        }
                        if (dgvMember.Rows[j].Cells[k].Value != null)
                        {

                            tempStr += dgvMember.Rows[j].Cells[k].Value.ToString();
                        }
                        else
                        {
                            tempStr += "";
                        }
                    }
                    sw.WriteLine(tempStr);
                }
                sw.Close();
                myStream.Close();
                MessageBox.Show("导出成功");
            }
            catch (Exception err)
            {
                MessageBox.Show(err.ToString());
            }
            finally
            {
                sw.Close();
                myStream.Close();
            }
        }

        private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
           // Printer Printer = new Printer(dgvMember, printDocument1);
           // Printer.Print(e.Graphics);
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            int sex=0;
            if (comboBox1.Text == "男")
            {
                sex = 1;
            }
            else if(comboBox1.Text=="女")
            {
                sex = 0;
            }
            string strMember = this.txtMember.Text;
            bool bEnabled = this.chkEnabled.Checked;
            List<Member> lstMember = new Member().Selectsexlist(strMember, bEnabled,sex);
            this.dgvMember.AutoGenerateColumns = false;
            this.dgvMember.Rows.Clear();
            decimal dSum = 0;//合计余额
            foreach (Member objMember in lstMember)
            {
                dSum += objMember.Balance;
                this.dgvMember.Rows.Add(new object[] { objMember.ID, objMember.Card.CardName, objMember.Name, objMember.SexText, objMember.Birthday, objMember.Balance, objMember.Point, objMember.Phone, objMember.LastTime, objMember.StatusText, objMember.Other, objMember.Remark });
            }
            this.lblSumBalance.Text = "会员余额合计：￥" + dSum.ToString("f2");

            this.lblSumBalance.Top = this.ClientSize.Height - 18;
        }

        private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
        {
            //jz();
            int sex = 0;
            SqlConnection conn = new SqlConnection(constr);
            conn.Open();
            //查寻卡类型对应ID
            string sql=string.Format( "SELECT [cid] FROM [card] where cname='{0}'",comboBox2.Text);
            SqlCommand comm = new SqlCommand(sql,conn);
            SqlDataReader sdr = comm.ExecuteReader();
            while (sdr.Read())
            {
                sex = Int32.Parse(sdr["cid"].ToString());
            }
            string strMember = this.txtMember.Text;
            bool bEnabled = this.chkEnabled.Checked;
            List<Member> lstMember = new Member().Selectcardfllist(strMember, bEnabled, sex);
            this.dgvMember.AutoGenerateColumns = false;
            this.dgvMember.Rows.Clear();
            decimal dSum = 0;//合计余额
            foreach (Member objMember in lstMember)
            {
                dSum += objMember.Balance;
                this.dgvMember.Rows.Add(new object[] { objMember.ID, objMember.Card.CardName, objMember.Name, objMember.SexText, objMember.Birthday, objMember.Balance, objMember.Point, objMember.Phone, objMember.LastTime, objMember.StatusText, objMember.Other, objMember.Remark });
            }
            this.lblSumBalance.Text = "会员余额合计：￥" + dSum.ToString("f2");

            this.lblSumBalance.Top = this.ClientSize.Height - 18;
        }

        private void comboBox2_Click(object sender, EventArgs e)
        {
            jz();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            //判断tljb表是否有此人数据，没有则增加

            if (sfcz() == true)
            {
                chuanzhi.tlcard = dgvMember.SelectedCells[0].Value.ToString();
                chuanzhi.tlname = dgvMember.SelectedCells[2].Value.ToString();
                frmdangan da = new frmdangan();
                da.ShowDialog();
            }
            else
            {
                //tljb表增加
                SqlConnection conn = new SqlConnection(constr);
                conn.Open();
                string sql =string.Format( "INSERT INTO [tljb] ([卡号] ,[颈椎病] ,[肩周炎] ,[风湿] ,[腰肌劳损] ,[腰间盘] ,[关节炎]  ,[养肾护肾] ,[高低血压]  ,[失眠] ,[内分泌失调] ,[色斑] ,[痤疮],[更年期综合征] ,[痛经]  ,[阴道炎] ,[附件炎]   ,[盆腔炎] ,[盆腔积液] ,[宫颈炎] ,[宫颈糜烂] ,[其他妇科炎症] ,[其他]) VALUES ('{0}'   ,0 ,0  ,0 ,0 ,0 ,0 ,0 ,0  ,0  ,0 ,0  ,0 ,0  ,0 ,0 ,0,0,0,0 ,0 ,0 ,'')", dgvMember.SelectedCells[0].Value.ToString());
                SqlCommand comm = new SqlCommand(sql,conn);
                comm.ExecuteNonQuery();
                conn.Close();
                chuanzhi.tlcard = dgvMember.SelectedCells[0].Value.ToString();
                chuanzhi.tlname = dgvMember.SelectedCells[2].Value.ToString();
                frmdangan da = new frmdangan();
                da.ShowDialog();
            }
        }
        public bool sfcz()
        {
            SqlConnection conn = new SqlConnection(constr);
            conn.Open();
            string sql =string.Format( "SELECT * FROM [tljb] where 卡号='{0}'", dgvMember.SelectedCells[0].Value.ToString());
            SqlDataAdapter sda = new SqlDataAdapter(sql,conn);
            DataTable dt = new DataTable();
            sda.Fill(dt);
            conn.Close();
            if (dt.Rows.Count > 0)
            {
                return true;
            }
            else
            {
                return false;
            }

        }

        private void button2_Click(object sender, EventArgs e)
        {
            DevExpress.XtraReports.UI.XtraReport xr = new DevExpress.XtraReports.UI.XtraReport();
            xr.LoadLayout(AppDomain.CurrentDomain.BaseDirectory + @"bb\Reportkhxinxi.repx");
            xr.DataSource = dayin();
            xr.ShowPreview();
        }
        public DataSet dayin()
        {
            SqlConnection conn = new SqlConnection(constr);
            conn.Open();
            string sql =string.Format("select member.mid, member.mname, member.mstatus,  member.mcid, member.mpass, member.mremark, member.msex, member.mmonth, member.mday, member.mphone, member.maddress, member.mother, member.mjoin, member.midcard, member.mbalance, member.mpoint, member.mlastime, member.image,member.ifyxq, member.yxq, member.shengao, member.tizhong, member.xiongwei, member.yaowei, member.tunwei, member.zdy, member.biwei, member.tuiwei, member.age, tljb.id, tljb.卡号, case(tljb.颈椎病) when 0 then '否' when 1 then '是' end as 颈椎病 , case(tljb.肩周炎) when 0 then '否' when 1 then '是' end as 肩周炎, case(tljb.风湿) when 0 then '否' when 1 then '是' end as 风湿, case(tljb.腰肌劳损) when 0 then '否' when 1 then '是' end as '腰肌劳损',case(tljb.腰间盘) when 0 then '否' when 1 then '是' end as 腰间盘,case( tljb.关节炎) when 0 then '否' when 1 then '是' end as 关节炎,case( tljb.养肾护肾) when 0 then '否' when 1 then '是' end as 养肾护肾, case(tljb.高低血压) when 0 then '否' when 1 then '是' end as 高低血压 ,case(tljb.失眠) when 0 then '否' when 1 then '是' end as 失眠, case(tljb.内分泌失调) when 0 then '否' when 1 then '是' end as 内分泌失调,case(tljb.色斑) when 0 then '否' when 1 then '是' end as 色斑, case(tljb.痤疮) when 0 then '否' when 1 then '是' end  as 痤疮,case( tljb.更年期综合征) when 0 then '否' when 1 then '是' end as 更年期综合征, case(tljb.痛经) when 0 then '否' when 1 then '是' end as 痛经,case(tljb.阴道炎) when 0 then '否' when 1 then '是' end as 阴道炎, case(tljb.附件炎) when 0 then '否' when 1 then '是' end as 附件炎, case(tljb.盆腔炎) when 0 then '否' when 1 then '是' end as 盆腔炎, case(tljb.盆腔积液) when 0 then '否' when 1 then '是' end as 盆腔积液, case(tljb.宫颈炎) when 0 then '否' when 1 then '是' end as 宫颈炎, case(tljb.宫颈糜烂) when 0 then '否' when 1 then '是' end as 宫颈糜烂, case(tljb.其他妇科炎症) when 0 then '否' when 1 then '是' end as 其他妇科炎症, tljb.其他,card.cid,card.cname from (dbo.member member inner join dbo.tljb tljb on (tljb.卡号 = member.mid)) inner join dbo.card card on (card.cid = member.mcid) where mid='{0}'", dgvMember.SelectedCells[0].Value.ToString());
            SqlDataAdapter sda = new SqlDataAdapter(sql,conn);
            DataSet ds = new DataSet();
            sda.Fill(ds,"member");
            conn.Close();
            return ds;
        }

        private void button3_Click(object sender, EventArgs e)
        {
            DevExpress.XtraReports.UI.XtraReport xr = new DevExpress.XtraReports.UI.XtraReport();
            xr.LoadLayout(AppDomain.CurrentDomain.BaseDirectory + @"bb\Reportkhxinxi.repx");
            xr.Report.Name = "khxinxi";
            xr.ShowDesignerDialog();
            xr.SaveLayout(AppDomain.CurrentDomain.BaseDirectory + @"bb\Reportkhxinxi.repx");
            xr.Dispose();
        }

        private void 修改积分ToolStripMenuItem_Click(object sender, EventArgs e)
        {

            if (this.dgvMember.CurrentRow != null)
            {

                chuanzhi cz = new chuanzhi();
                cz.rizhi("修改积分,卡号：" + this.dgvMember.CurrentRow.Cells[0].Value.ToString());
                chuanzhi.xiugai_cardid = this.dgvMember.CurrentRow.Cells[0].Value.ToString();
                修改积分 xg = new 修改积分();
                xg.ShowDialog();
                this.LoadMemberList();
                this.LoadMemberNum();
            }
       }
    }
}
